Skip to content

[SV-COMP'18 12/19] SV-COMP graphml fixes [blocks: #3486] #2001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Apr 17, 2019

Conversation

tautschnig
Copy link
Collaborator

Do not merge as-is: this needs cleanup of patches and of the changes to expr2ct.

@tautschnig tautschnig changed the title [SV-COMP'18 11/19] SV-COMP graphml fixes [SV-COMP'18 12/19] SV-COMP graphml fixes Apr 3, 2018
@tautschnig tautschnig self-assigned this Apr 5, 2018
@@ -699,6 +699,7 @@ std::string expr2ct::convert_struct_type(
if(tag!="")
dest+=" "+id2string(tag);

#if 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment explaining why?

std::string result;

if(assign.rhs().id()==ID_array)
if(assign.rhs().id()=="array-list")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ID, or add one if not already present

exprt clean_lhs=assign.lhs();
remove_l0_l1(clean_lhs);
std::string lhs=from_expr(ns, identifier, clean_lhs);
if(lhs.find("#return_value")!=std::string::npos ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ID

return false;
}

static bool contains_symbol_prefix(const exprt &expr, const std::string &prefix){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use depth_begin et al instead of recursing?

{
nodes.push_back(graphml.add_node());
graphml[nodes.back()].node_name="N" + std::to_string(i);
graphml[nodes.back()].is_violation=(i==max_thread_idx+1U) ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that ternary conditional is redundant

graphml[nodes.back()].has_invariant=false;
}

for(auto it=nodes.cbegin(); std::next(it)!=nodes.cend(); ++it)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INVARIANT(!nodes.empty())?

}
else if(
id2string(it->lhs_object.get_identifier())
.find("#return_value")==std::string::npos &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several well-known identifiers to ID-ify here

@@ -300,33 +428,13 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace)
else if(it->type==goto_trace_stept::typet::GOTO &&
it->pc->is_goto())
{
#if 0
// TODO: this requires knowledge about the phase of the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide an issue reference?

inline void hash_combine(std::size_t & seed, const T & v)
{
std::hash<T> hasher;
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide a reference for the particular source of magic numbers?

@tautschnig
Copy link
Collaborator Author

This PR is now actually ready for review. We certainly have a lot of problems left to resolve, but that would at least get develop to have the GraphML witness code that we've been using in SV-COMP the last years.

@tautschnig tautschnig force-pushed the sv-comp-graphml branch 2 times, most recently from 4fa3782 to c958e2a Compare March 23, 2019 22:37
@tautschnig tautschnig changed the title [SV-COMP'18 12/19] SV-COMP graphml fixes [SV-COMP'18 12/19] SV-COMP graphml fixes [blocks: #3486] Mar 23, 2019
@tautschnig tautschnig force-pushed the sv-comp-graphml branch 2 times, most recently from ace5f4f to 808a00e Compare March 25, 2019 11:23
@@ -1866,6 +1869,27 @@ std::string expr2ct::convert_constant(
else if(dest=="-NaN")
dest="-NAN";
}
else if(dest.size() == 4 && (dest[0] == '+' || dest[0] == '-'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combine this and the case above to remove the redundant expression dest.size() == 4 && (dest[0] == '+' || dest[0] == '-')

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to keep the diff smaller, but will now do as suggested.

namespace std // NOLINT(readability/namespace)
{
template <typename S, typename T>
struct hash<pair<S, T>> // NOLINT(readability/identifiers)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely this belongs in util somewhere

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it has this single user...

std::string graphml_witnesst::convert_assign_rec(
const irep_idt &identifier,
const code_assignt &assign)
{
static std::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite surprised the lifetime of this cache isn't tied to that of some class, rather than living as long as the process

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make it a class member.

graphml[*it].out[*std::next(it)].xml_node = edge;
}

// we do not provide any further details as CPAchecker does not seem to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps link to some appropriate issue or discussion thread?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A link to furious discussions at the SV-COMP meeting in Thessaloniki? :-) Or maybe sosy-lab/sv-witnesses#12?

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: ee2c68b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/105821202

peterschrammel and others added 16 commits April 4, 2019 21:23
https://github.com/sosy-lab/sv-witnesses documents a "control" node, and
examples still include "sourcecode" nodes, but there neither is
documented semantics for "control" nodes nor is it clear whether the
"sourcecode" node is used by any tool.
The witness format documentation only states "Nodes where this flag is
set must not have any leaving transitions" for sink nodes, but quite
possibly validators expect the same for violation nodes.
NULL, NAN, INFINITY are not a keywords, just macros. Do not use them for
output under the "clean" configuration.
Witness validators expect syntactically correct C code, not
human-friendly pseudo-C.
Witness validators expect syntactically correct C code, and cannot cope
with SSA suffixes.
The witness specification permits use of \result in assumptions (in
violation witnesses), but then also requires setting
assumption.resultfunction.
We must not filter out generated assertions for memory leaks.
Witness validators cannot handle array lists.
These symbols do not occur in the input program.
Witness validators cannot be expected to understand CBMC's "with"
expressions.

Fixes: diffblue#4486
It's actually not clear whether this is necessary or permitted, it's not
contained in the official specification.
Expression-to-string conversion is costly.
This does likely need more work, but at least got us some points in the
past.
We would previously use the name of the calling function. Instead,
parameter assignments require a special case. Regression test kindly
provided by @JanSvejda.

Fixes: diffblue#4418
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 16a59aa).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/107154317
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.

@kroening kroening merged commit 51e0cd7 into diffblue:develop Apr 17, 2019
@tautschnig tautschnig deleted the sv-comp-graphml branch April 17, 2019 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants